package com.appwoo.txtws.wheel.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.appwoo.txtws.component.Logger;

public class PullPageListView extends AbsPageListView
{
  private static final String TAG = PullPageListView.class.getSimpleName();
  private AbsPageListView.OnRefreshListener footerFreshListener;
  private FooterView footerView;
  private AbsPageListView.OnRefreshListener headerFreshListener;
  private HeaderView headerView;

  public PullPageListView(Context paramContext)
  {
    super(paramContext);
    init(paramContext);
  }

  public PullPageListView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    init(paramContext);
  }

  public PullPageListView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    init(paramContext);
  }

  private void init(Context paramContext)
  {
    setOnTouchListener(null);
    LayoutInflater localLayoutInflater = (LayoutInflater)paramContext.getSystemService("layout_inflater");
    this.headerView = new HeaderView(paramContext, localLayoutInflater, null);
    addHeaderView(this.headerView.getView());
    this.headerView.showLoading();
    this.footerView = new FooterView(paramContext, localLayoutInflater, null);
    addFooterView(this.footerView.getView());
  }

  public void onLoadComplete(boolean paramBoolean)
  {
    boolean bool = this.headerView.isLoading;
    this.headerView.hideView();
    this.footerView.showMore();
    if (bool)
      setSelection(1);
    if (paramBoolean)
      this.footerView.hideView();
  }

  public void setFooterRefreshListener(AbsPageListView.OnRefreshListener paramOnRefreshListener)
  {
    this.footerFreshListener = paramOnRefreshListener;
  }

  public void setHeaderRefreshListener(AbsPageListView.OnRefreshListener paramOnRefreshListener)
  {
    this.headerFreshListener = paramOnRefreshListener;
    this.headerView.showLoadingNoExec();
  }

  public void setOnTouchListener(View.OnTouchListener paramOnTouchListener)
  {
    super.setOnTouchListener(new PullTouchListener(paramOnTouchListener));
  }

  public void showHeaderLoading()
  {
    this.headerView.showLoadingNoExec();
  }

  private class FooterView
  {
    private ProgressBar footerProgress;
    private TextView footerText;
    private RelativeLayout footerView;
    boolean isloading = false;

    private FooterView(Context paramLayoutInflater, LayoutInflater arg3)
    {
      Object localObject;
      this.footerView = ((RelativeLayout)localObject.inflate(2130903153, null));
      this.footerProgress = ((ProgressBar)this.footerView.findViewById(2131493281));
      this.footerText = ((TextView)this.footerView.findViewById(2131493282));
      this.footerView.setOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          if (!PullPageListView.FooterView.this.isloading)
          {
            PullPageListView.FooterView.this.showLoading();
            if (PullPageListView.this.footerFreshListener != null)
              PullPageListView.this.footerFreshListener.onRefresh();
          }
        }
      });
    }

    private View getView()
    {
      return this.footerView;
    }

    private void hideView()
    {
      this.isloading = false;
      this.footerProgress.setVisibility(8);
      this.footerText.setVisibility(8);
    }

    private void showLoading()
    {
      this.isloading = true;
      this.footerProgress.setVisibility(0);
      this.footerText.setVisibility(0);
      this.footerText.setText(2131428047);
    }

    private void showMore()
    {
      this.isloading = false;
      this.footerProgress.setVisibility(8);
      this.footerText.setVisibility(0);
      this.footerText.setText(2131428044);
    }
  }

  private class HeaderView
  {
    private RotateAnimation animation;
    private ImageView headerImage;
    private ProgressBar headerProgress;
    private TextView headerText;
    private RelativeLayout headerView;
    private boolean isLoading = false;
    private boolean isShowPull = false;
    private RotateAnimation reverseAnimation;

    private HeaderView(Context paramLayoutInflater, LayoutInflater arg3)
    {
      Object localObject;
      this.headerView = ((RelativeLayout)localObject.inflate(2130903154, null));
      this.headerText = ((TextView)this.headerView.findViewById(2131493285));
      this.headerImage = ((ImageView)this.headerView.findViewById(2131493284));
      this.headerProgress = ((ProgressBar)this.headerView.findViewById(2131493283));
      this.animation = initRotateAnimation(0.0F, -180.0F);
      this.reverseAnimation = initRotateAnimation(-180.0F, 0.0F);
    }

    private void execAnimation(RotateAnimation paramRotateAnimation)
    {
      this.headerImage.clearAnimation();
      this.headerImage.startAnimation(paramRotateAnimation);
    }

    private View getView()
    {
      return this.headerView;
    }

    private void hideView()
    {
      this.isLoading = false;
      this.isShowPull = false;
      this.headerImage.setVisibility(8);
      this.headerText.setVisibility(8);
      this.headerProgress.setVisibility(8);
    }

    private RotateAnimation initRotateAnimation(float paramFloat1, float paramFloat2)
    {
      RotateAnimation localRotateAnimation = new RotateAnimation(paramFloat1, paramFloat2, 1, 0.5F, 1, 0.5F);
      localRotateAnimation.setInterpolator(new LinearInterpolator());
      localRotateAnimation.setDuration(250L);
      localRotateAnimation.setFillAfter(true);
      return localRotateAnimation;
    }

    private void showLoading()
    {
      showLoadingNoExec();
      if (PullPageListView.this.headerFreshListener != null)
        PullPageListView.this.headerFreshListener.onRefresh();
    }

    private void showLoadingNoExec()
    {
      this.isLoading = true;
      this.isShowPull = false;
      this.headerImage.clearAnimation();
      this.headerImage.setImageResource(2130837738);
      this.headerImage.setVisibility(8);
      this.headerText.setVisibility(0);
      this.headerProgress.setVisibility(0);
      this.headerText.setText(2131428047);
    }

    private void showPull()
    {
      this.isLoading = false;
      this.isShowPull = true;
      this.headerImage.setVisibility(0);
      this.headerText.setVisibility(0);
      this.headerProgress.setVisibility(8);
      this.headerText.setText(2131428046);
    }
  }

  private class PullTouchListener
    implements View.OnTouchListener
  {
    boolean ami = false;
    boolean reTouch = false;
    int reY = 25;
    int showY = 20;
    View.OnTouchListener subListener;
    int touchY = 0;

    public PullTouchListener(View.OnTouchListener arg2)
    {
      Object localObject;
      this.subListener = localObject;
    }

    private void prepareHeader(int paramInt)
    {
      if (!PullPageListView.access$0(PullPageListView.this).isShowPull)
      {
        Logger.i(PullPageListView.TAG, "isShowPull");
        PullPageListView.this.headerView.showPull();
      }
      if (paramInt > this.reY)
        if (!this.ami)
        {
          PullPageListView.this.headerView.execAnimation(PullPageListView.access$0(PullPageListView.this).animation);
          this.ami = true;
        }
      while (!this.ami)
        return;
      PullPageListView.this.headerView.execAnimation(PullPageListView.access$0(PullPageListView.this).reverseAnimation);
      this.ami = false;
    }

    void initdata()
    {
      this.touchY = 0;
      this.reTouch = false;
      this.ami = false;
    }

    public boolean onTouch(View paramView, MotionEvent paramMotionEvent)
    {
      if (PullPageListView.access$0(PullPageListView.this).isLoading);
      while (true)
      {
        return false;
        int i = (int)paramMotionEvent.getY();
        int j = PullPageListView.this.getFirstVisiblePosition();
        switch (paramMotionEvent.getAction())
        {
        default:
        case 1:
        case 0:
        case 2:
        }
        while (this.subListener != null)
        {
          return this.subListener.onTouch(paramView, paramMotionEvent);
          if ((j == 0) && (this.reTouch))
          {
            if (i - this.touchY >= this.reY)
              break label121;
            PullPageListView.this.headerView.hideView();
          }
          while (true)
          {
            initdata();
            break;
            label121: PullPageListView.this.headerView.showLoading();
          }
          initdata();
          continue;
          if (j == 0)
            if (!this.reTouch)
            {
              this.reTouch = true;
              this.touchY = i;
            }
            else
            {
              int k = i - this.touchY;
              if (k > this.showY)
                prepareHeader(k);
            }
        }
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.wheel.widget.PullPageListView
 * JD-Core Version:    0.6.2
 */